export const flat =  function(arr) {
    let res = []
    arr.forEach(item => {
        res.push(Array.isArray(item) ? flat(item) : item)
    });
    return res
}

export const reduceFlat = function(arr, depth) {
    return depth > 0 ?
    arr.reduce((pre, cur) => {
        return pre.concat(Array.isArray(cur) ? reduceFlat(cur, depth - 1) : cur)
    }, []) : arr.slice()
    
}